/*******************************************************************************
 *                                    ZLG
 *                         ----------------------------
 *                         innovating embedded platform
 *
 * Copyright (c) 2001-present Guangzhou ZHIYUAN Electronics Co., Ltd.
 * All rights reserved.
 *
 * Contact information:
 * web site:    https://www.zlg.cn
 *******************************************************************************/
#ifndef __HPM6E00_REGS_GPTIMER_H
#define __HPM6E00_REGS_GPTIMER_H

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus*/
#include "core/include/hpm6e00_regs_base.h"
#include <stdint.h>

#define GPTMR_CHANNEL_CR_SYNCFLW_POS    (13U)
#define GPTMR_CHANNEL_CR_SYNCFLW_MASK   (0x1U << GPTMR_CHANNEL_CR_SYNCFLW_POS)
#define GPTMR_CHANNEL_CR_SYNCIFEN_POS   (12U)      /* 下降沿 SYNCI 有效 */
#define GPTMR_CHANNEL_CR_SYNCIFEN_MASK  (0x1U << GPTMR_CHANNEL_CR_SYNCIFEN_POS)
#define GPTMR_CHANNEL_CR_SYNCIREN_POS   (11U)      /* 上升沿 SYNCI 有效 */
#define GPTMR_CHANNEL_CR_SYNCIREN_MASK  (0x1U << GPTMR_CHANNEL_CR_SYNCIREN_POS)
#define GPTMR_CHANNEL_CR_CEN_POS        (10U)      /* 计数器使能位 */
#define GPTMR_CHANNEL_CR_CEN_MASK       (0x1U << GPTMR_CHANNEL_CR_CEN_POS)
#define GPTMR_CHANNEL_CR_CMPINIT_POS    (9U)       /* 通道输出比较功能初始化 */
#define GPTMR_CHANNEL_CR_CMPINIT_MASK   (0x1U << GPTMR_CHANNEL_CR_CMPINIT_POS)
#define GPTMR_CHANNEL_CR_CMPEN_POS      (8U)       /* 通道输出比较功能使能位 */
#define GPTMR_CHANNEL_CR_CMPEN_MASK     (0x1U << GPTMR_CHANNEL_CR_CMPEN_POS)
#define GPTMR_CHANNEL_CR_DMASEL_POS     (6U)       /* DMA 请求选择 */
#define GPTMR_CHANNEL_CR_DMASEL_MASK    (0x3U << GPTMR_CHANNEL_CR_DMASEL_POS)
#define GPTMR_CHANNEL_CR_DMAEN_POS      (5U)       /* DMA 使能位 */
#define GPTMR_CHANNEL_CR_DMAEN_MASK     (0x1U << GPTMR_CHANNEL_CR_DMAEN_POS)
#define GPTMR_CHANNEL_CR_SWSYNCIEN_POS  (4U)       /* 软件同步使能位 */
#define GPTMR_CHANNEL_CR_SWSYNCIEN_MASK (0x1U << GPTMR_CHANNEL_CR_SWSYNCIEN_POS)
#define GPTMR_CHANNEL_CR_DBGPAUSE_POS   (3U)       /* 调试停止模式使能位 */
#define GPTMR_CHANNEL_CR_DBGPAUSE_MASK  (0x1U << GPTMR_CHANNEL_CR_DBGPAUSE_POS)
#define GPTMR_CHANNEL_CR_CAPMODE_POS    (0U)       /* 输入捕获模式使能位 */
#define GPTMR_CHANNEL_CR_CAPMODE_MASK   (0x7U << GPTMR_CHANNEL_CR_CAPMODE_POS)

/* \brief 重载寄存器位定义*/
#define GPTMR_CHANNEL_RLD_RLD_POS       (0U)
#define GPTMR_CHANNEL_RLD_RLD_MASK      (0xFFFFFFFFUL)

/* \brief 比较寄存器位定义*/
#define GPTMR_CMP_CMP_POS               (0U)
#define GPTMR_CMP_CMP_MASK              (0xFFFFFFFFUL)

/* \brief 通用定时器寄存器定义 */
typedef struct {
    struct {
        volatile uint32_t       CR;                      /* 0x0: Control Register */
        volatile uint32_t       CMP[2];                  /* 0x4 - 0x8: Comparator register 0 */
        volatile uint32_t       RLD;                     /* 0xC: Reload register */
        volatile uint32_t       CNTUPTVAL;               /* 0x10: Counter update value register */
        volatile const uint8_t  RESERVED0[12];           /* 0x14 - 0x1F: Reserved */
        volatile const uint32_t CAPPOS;                  /* 0x20: Capture rising edge register */
        volatile const uint32_t CAPNEG;                  /* 0x24: Capture falling edge register */
        volatile const uint32_t CAPPRD;                  /* 0x28: PWM period measure register */
        volatile const uint32_t CAPDTY;                  /* 0x2C: PWM duty cycle measure register */
        volatile const uint32_t CNT;                     /* 0x30: Counter */
        volatile const uint8_t  RESERVED1[12];           /* 0x34 - 0x3F: Reserved */
    } CHANNEL[4];
    volatile const uint8_t      RESERVED0[256];          /* 0x100 - 0x1FF: Reserved */
    volatile uint32_t           SR;                      /* 0x200: Status register */
    volatile uint32_t           IRQEN;                   /* 0x204: Interrupt request enable register */
    volatile uint32_t           GCR;                     /* 0x208: Global control register */
} hpm_gptmr_reg_t;



#define HPM_GPTMR0  ((hpm_gptmr_reg_t *)HPM_GPTMR0_BASE)
#define HPM_GPTMR1  ((hpm_gptmr_reg_t *)HPM_GPTMR1_BASE)
#define HPM_GPTMR2  ((hpm_gptmr_reg_t *)HPM_GPTMR2_BASE)
#define HPM_GPTMR3  ((hpm_gptmr_reg_t *)HPM_GPTMR3_BASE)
#define HPM_GPTMR4  ((hpm_gptmr_reg_t *)HPM_GPTMR4_BASE)
#define HPM_GPTMR5  ((hpm_gptmr_reg_t *)HPM_GPTMR5_BASE)
#define HPM_GPTMR6  ((hpm_gptmr_reg_t *)HPM_GPTMR6_BASE)
#define HPM_GPTMR7  ((hpm_gptmr_reg_t *)HPM_GPTMR7_BASE)


#ifdef __cplusplus
}
#endif  /* __cplusplus  */
#endif


